package com.mysecurity.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.mysecurity.pojo.Role;
import com.mysecurity.pojo.UserRole;
import com.mysecurity.service.RoleService;
import com.mysecurity.mapper.RoleMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role>
    implements RoleService{

    @Resource
    RoleMapper roleMapper;

    @Override
    public List<Role> getRoleListByUserId(Long uid) {
        //多表连接
        List<Role> roleList = roleMapper.selectJoinList(Role.class
                ,new MPJLambdaWrapper<Role>()
                        .selectAll(Role.class)
                        .innerJoin(UserRole.class,UserRole::getRoleId,Role::getId)
                        .eq(UserRole::getUserId,uid)

        );
        return roleList;
    }
}




